package com.ziyun.erp.web.modules.capital.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ziyun.erp.modules.capital.entity.MerchantFlowEntity;
import com.ziyun.erp.modules.capital.service.MerchantFlowService;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.common.validator.ValidatorUtils;

/**
 * 
 *
 * @author zh
 * @email 296588519@qq.com
 * @date 2018-08-03 10:29:41
 */
@RestController
@RequestMapping("capital/merchantflow")
public class MerchantFlowController {
	@Autowired
	private MerchantFlowService merchantFlowService;

	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("capital:merchantflow:list")
	public R list(@RequestParam Map<String, Object> params) {
		PageUtils page = merchantFlowService.queryPage(params);

		return R.ok().put("page", page);
	}

	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("capital:merchantflow:info")
	public R info(@PathVariable("id") Integer id) {
		MerchantFlowEntity merchantFlow = merchantFlowService.selectById(id);

		return R.ok().put("merchantFlow", merchantFlow);
	}

	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("capital:merchantflow:save")
	public R save(@RequestBody MerchantFlowEntity merchantFlow) {
		merchantFlowService.insert(merchantFlow);

		return R.ok();
	}

	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("capital:merchantflow:update")
	public R update(@RequestBody MerchantFlowEntity merchantFlow) {
		ValidatorUtils.validateEntity(merchantFlow);
		merchantFlowService.updateAllColumnById(merchantFlow);// 全部更新

		return R.ok();
	}

	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("capital:merchantflow:delete")
	public R delete(@RequestBody Integer[] ids) {
		merchantFlowService.deleteBatchIds(Arrays.asList(ids));

		return R.ok();
	}

}
